﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using Planetwork.App_Code;

namespace Planetwork
{
    public partial class Home : BasePage
    {
        static string conStr = ConfigurationManager.AppSettings["conStr"];
        SqlConnection mycon = new SqlConnection(conStr);
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["index"] == null)
                Response.Redirect("../Default.aspx");
            else
            {
                try
                {
                    string index = Request.QueryString["index"];
                    string sql = "select *from DefaultImage where Id=" + index;
                    SqlDataAdapter mydat = new SqlDataAdapter(sql, mycon);
                    DataSet myds = new DataSet();
                    mycon.Open();
                    mydat.Fill(myds);
                    mycon.Close();

                    if (myds.Tables[0].Rows.Count > 0)
                    {
                        this.showContent.Text = myds.Tables[0].Rows[0]["Content"].ToString();
                    }
                    else
                    {
                        Response.Write("<script>alert('数据错误!');window.location.href ='Default.aspx'</script>");
                    }
                }       
                catch(Exception ex)
                {                 
                    Response.Write("<script>alert('" + ex.ToString() + "');window.location.href ='Default.aspx';</script>");
                }
            }
        }

    }
}